package club.zhilin.guli.service.edu.service.impl;

import club.zhilin.guli.service.edu.domain.Video;
import club.zhilin.guli.service.edu.feign.VodMediaService;
import club.zhilin.guli.service.edu.mapper.VideoMapper;
import club.zhilin.guli.service.edu.service.IVideoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 课程视频 服务实现类
 * </p>
 *
 * @author zhilin
 * @since 2022-01-11 15:29:01
 */
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class VideoServiceImpl extends ServiceImpl<VideoMapper, Video> implements IVideoService {
    private final VodMediaService vodMediaService;

    @Override
    public void removeMediaVideo(String id) {
        Video video = baseMapper.selectOne(new LambdaQueryWrapper<Video>().select(Video::getVideoSourceId).eq(Video::getId, id));
        if (video == null) {
            return;
        }
        vodMediaService.removeVideo(video.getVideoSourceId());
    }
}
